package com.insurance.controller;

import com.insurance.common.Contants;
import com.insurance.common.ResultData;
import com.insurance.pojo.Information;
import com.insurance.service.PublicCityService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/10/29 10:32
 * Description:
 * Version: V1.0
 */
@Api(value = "公用接口（查询省市区，用户司机消息）",tags = "公用接口（查询省市区，用户司机消息）")
@Controller
@RequestMapping("/city")
public class PublicCityController {

    @Autowired
    PublicCityService publicCityService;

    @Autowired
    ResultData resultData;

    @ResponseBody
    @GetMapping(value = "/queryByCity.do", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询所有市信息",notes = "查询所有市信息接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResultData queryByCity(int provinceId) throws SQLException {
        resultData.setCode(Contants.SUCCESS);
        ResultData resultDataqueryByCity=publicCityService.queryByCity(provinceId);
        return resultDataqueryByCity;
    }
    @ResponseBody
    @GetMapping(value = "/queryByProvinceDriver.do", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询所有省",notes = "查询所有省接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResultData queryByProvinceDriver() throws SQLException {
        resultData.setCode(Contants.SUCCESS);
        ResultData resultDataqueryByCity=publicCityService.queryByProvinceDriver();
        return resultDataqueryByCity;
    }

    @ResponseBody
    @GetMapping(value = "/queryByAreaDriver.do", produces = "application/json;charset=utf-8")
    @ApiOperation(value = "查询市下的区域",notes = "查询市下的区域接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResultData queryByAreaDriver(int cityId) throws SQLException {
        resultData.setCode(Contants.SUCCESS);
        ResultData resultDataqueryByCity=publicCityService.queryByAreaDriver(cityId);
        return resultDataqueryByCity;
    }



    @RequestMapping(value = "/queryunreadInformByUserId.do",method = RequestMethod.GET)
    @ApiOperation(value = "司机用户查询未读消息",notes = "查询未读消息接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "user_id",value = "用户id",required = true)
    @ResponseBody
    public ResultData queryunreadInformByUserId(@RequestParam int user_id){
        ResultData resultData=publicCityService.queryunreadInformByUserId(user_id);
        return resultData;
    }


    @RequestMapping(value = "/queryreadInformByUserId.do",method = RequestMethod.GET)
    @ApiOperation(value = "司机用户查询已读消息",notes = "查询已读消息接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "user_id",value = "用户id",required = true)
    @ResponseBody
    public ResultData queryreadInformByUserId(@RequestParam int user_id){
        ResultData resultData=publicCityService.queryreadInformByUserId(user_id);
        return resultData;
    }


    @RequestMapping(value = "/readInformByUserId.do",method = RequestMethod.GET)
    @ApiOperation(value = "司机用户修改用户消息为已读消息",notes = "修改用户消息为已读消息接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="修改成功"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "user_id",value = "用户id",required = true)
    @ResponseBody
    public ResultData readInformByUserId(@RequestParam int user_id){
        ResultData resultData=publicCityService.readInformByUserId(user_id);
        return resultData;
    }


    @RequestMapping(value = "/verificationUserName.do",method = RequestMethod.GET)
    @ApiOperation(value = "判断用户名是否重复",notes = "判断用户名是否重复接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="可以使用"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "userName",value = "用户名",required = true)
    @ResponseBody
    public ResultData verificationUserName(@RequestParam String userName){
        ResultData resultData=publicCityService.verificationUserName(userName);
        return resultData;
    }
    @RequestMapping(value = "/updateverificationUserName.do",method = RequestMethod.GET)
    @ApiOperation(value = "查询除传入user_id之外的用户",notes = "查询除传入user_id之外的用户接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "user_id",value = "用户id",required = true)
    @ResponseBody
    public ResultData updateverificationUserName(@RequestParam Integer user_id){
        ResultData resultData=publicCityService.updateverificationUserName(user_id);
        return resultData;
    }
    @RequestMapping(value = "/verificationUserPhone.do",method = RequestMethod.GET)
    @ApiOperation(value = "判断用户电话是否重复",notes = "判断用户电话是否重复接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="可以使用"),
            @ApiResponse(code=500,message="后台服务错误"),

    })
    @ApiImplicitParam(name = "userPhone",value = "用户电话",required = true)
    @ResponseBody
    public ResultData verificationUserPhone(@RequestParam String userPhone){
        ResultData resultData=publicCityService.verificationUserPhone(userPhone);
        return resultData;
    }

 @RequestMapping(value = "/verificationUserEmail.do",method = RequestMethod.GET)
    @ApiOperation(value = "判断用户邮箱是否重复",notes = "判断用户邮箱是否重复接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="可以使用"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ApiImplicitParam(name = "userEmail",value = "用户电话",required = true)
    @ResponseBody
    public ResultData verificationUserEmail(@RequestParam String userEmail){
        ResultData resultData=publicCityService.verificationUserEmail(userEmail);
        return resultData;
    }

    @RequestMapping(value = "/rankingDriver.do",method = RequestMethod.GET)
    @ApiOperation(value = "司机排行",notes = "司机排行接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="可以使用"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ResponseBody
    public ResultData rankingDriver(){
        ResultData resultData=publicCityService.rankingDriver();
        return resultData;
    }
    @RequestMapping(value = "/countOrder.do",method = RequestMethod.GET)
    @ApiOperation(value = "订单统计",notes = "订单统计接口",httpMethod = "get",response = ResultData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="可以使用"),
            @ApiResponse(code=500,message="后台服务错误"),
    })
    @ResponseBody
    public ResultData countOrder(){
        ResultData resultData=publicCityService.countOrder();
        return resultData;
    }


}
